package com.ljh.extensions.rabbit.listener;

import com.ljh.extensions.rabbit.constants.Constants;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author: Themberfue
 * @date: 2025/5/2 11:20
 * @description:
 */
@Component
public class DelayListener {
    @RabbitListener(queues = Constants.DELAY_QUEUE)
    public void processDelay(Message message) throws Exception {
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        System.out.printf("%s：[%s]收到消息：%s，deliveryTag：%d\n",
                new Date(), Constants.DELAY_QUEUE, new String(message.getBody(), "UTF-8"), deliveryTag);
    }
}
